/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

class imoccApp extends Component {
  constructor(props){
    super(props)
    this.state = {times:0}
  }
  timePlus(){
    let times =this.state.times
    times++
    this.setState({
      times:times
    })
 }

componentWillMount(){
  console.log('ComponentWillMont','组件即将被安装')
}
render() {
    console.log('render','组件渲染')
  return (
    <View style={styles.container}>
      <Text style={styles.welcome}>
       有本事点我一下
      </Text>
      <Text style={styles.instructions}>
        To get started, edit index.ios.js
      </Text>
      <Text onPress= {this.timePlus.bind(this)} style={styles.instructions}>
         你点了我 {this.state.times}
      </Text>
    </View>
  );
}
componentDidMount(){
    console.log('ComponentWillMont','组件即将被安装完毕')
}
shouldComponentUpdate(){
  console.log('shouldComponentWillUpdate','要不要更新')
  return true
}
componentWillUpdate(){
    console.log('ComponentWillMont','组件即将被更新完毕')
}

componentDidUpdate(){
      console.log('componentDidUpdate','组件即将被更新完毕')
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('imoccApp', () => imoccApp);
